<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <title>layout</title>
  <style>
        .kuang {
            width: 600px;
            min-height: 500px;
            max-height: 296px;
            border: 1px solid;
            float: left;
            display: block;
            position: relative;
            overflow-y: scroll;
            
        }
    </style>
</head>
<body>
     
    <div class="container">
        <div class="row">
              <div class="jumbotron  bg-dark">
                <h1 class="jumbotron-heading">{{ . }}</h1>
              </div>
              <div>地址：<input  type="text" id="name1" />
                <button id="send">发送</button>
              </div>
            <div>
             <textarea cols="50" rows="30" id="from1"></textarea><br>
            </div> 
            <div class="input-group text-muted">
                <div class="kuang" id="mess"></div>
            </div>

        </div>
    </div>
</html>

<script language="javascript"type="text/javascript">
   var post = function (url,data,cb) {
        $.ajax({
            type: 'POST',
            url:url,
            contentType: "application/json; charset=utf-8",
            dataType:'string',
            data:JSON.stringify(data),
            success:function (res) {
                cb(res);
            }
        });
    }
    document.getElementById("send").onclick = function (e) {
        var url = "";
        var urlVal = name1.value
        if(urlVal.indexOf("http://") == -1){
            url = window.document.location.href + "/" + urlVal
        }else{
            url = urlVal
        }
        alert(from1.value)
        var val = from1.value;
        var vals = val.split("\n")
        var data = {}
        for(var i = 0; i < vals.length; i++){
            if(vals[i].indexOf("=") > -1){
                var vals2 = vals[i].split("=")
                data[vals2[0]] = vals2[1]
            }
        }
        if(data != {}){
             post(url,data, function(res){
                alert(res)
                mess.innerHTML = res
            });
        }
       
    }
</script>